<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>自然环境</title>
    <%@ include file="/WEB-INF/include/common.jsp"%>
    <%@ include file="/WEB-INF/include/commoncss.jsp"%>
    <style type="text/css">
        #uploader .placeholder .webuploader-pick{
            background:#5eb95e
        }
        #table_body button{
            margin:3px
        }
        #table_body tr{
            height: 10px;
        }
    </style>
</head>
<body>
<div class="page-container">
    <form action="${ctx }/Nature/InfoSearch" method="post" class="text-c">
        录入者账户:<input id="recoder_id" name="recoder_id" class="input-text"  style="width: 100px;"/>
        <button type="submit" class="btn btn-success radius" onclick="">
            <i class="Hui-iconfont">&#xe665;</i> 查询
        </button>
    </form>
    <div class="content">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
				 <span class="l">
					<a href="javascript:;" onclick="nature_add()" class="btn btn-success radius"><i class="Hui-iconfont"></i> 导入</a>
				</span>
            <span class="r"> <button type="button" class="btn btn-success radius" onclick="addNature()">添加</button>共有数据：<strong id="listsize">${nlist.size()} </strong> 条</span>
        </div>
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th>中文名字</th>

                <th>地理环境</th>
                <th >气候</th>
                <th >矿产资源</th>
                <th >生物资源</th>
                <th >能源资源</th>
                <th>操作人</th>
                <th>操作时间</th>
                <th >操作</th>
            </tr>
            </thead>
            <tbody id="table_body">
            <c:forEach items="${nlist }" var="i">
                <tr class="text-c">
                    <td>${i.nation_z }</td>
                    <td>
                        <c:if test="${fn:length(i.geography) > '10'}">
                            ${fn:substring(i.geography,0,10) }...
                        </c:if>
                        <c:if test="${fn:length(i.geography) <= '10'}">
                            ${i.geography}
                        </c:if>
                    </td>
                    <td>
                        <c:if test="${fn:length(i.climate) > '10'}">
                            ${fn:substring(i.climate,0,10) }...
                        </c:if>
                        <c:if test="${fn:length(i.climate) <= '10'}">
                            ${i.climate}
                        </c:if>
                    </td>
                    <td >
                        <c:if test="${fn:length(i.mineral_resource) > '10'}">
                            ${fn:substring(i.mineral_resource,0,10) }...
                        </c:if>
                        <c:if test="${fn:length(i.mineral_resource) <= '10'}">
                            ${i.mineral_resource}
                        </c:if>
                    </td>
                    <td>
                        <c:if test="${fn:length(i.biological_resource) > '10'}">
                            ${fn:substring(i.biological_resource,0,10) }...
                        </c:if>
                        <c:if  test="${fn:length(i.biological_resource) <= '10'}">
                            ${i.biological_resource}
                        </c:if>
                    </td>
                    <td>
                        <c:if test="${fn:length(i.energy_resource) > '10'}">
                            ${fn:substring(i.energy_resource,0,10) }...
                        </c:if>
                        <c:if  test="${fn:length(i.energy_resource) <= '10'}">
                            ${i.energy_resource}
                        </c:if>
                    </td>
                    <td>${i.recoder_id}</td>
                    <td>${i.recoder_time}</td>
                    <td>
<%--
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="nature_detail(this.value)"><i class="Hui-iconfont">&#xe6df;</i> 详情</button>
--%>
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="nature_update(this.value)"><i class="Hui-iconfont">&#xe685;</i> 修改</button>
                        <button type="button" class="btn btn-success radius" value="${i.country_code }" onclick="nature_delete(this.value)"><i class="Hui-iconfont">&#xe685;</i> 删除</button>

                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<%@ include file="/WEB-INF/include/commonjs.jsp"%>
<script type="text/javascript" src="${ctx}/javascript/laydate/laydate.js"></script>
<script type="text/javascript">
    $(function(){
        $('table tbody tr:odd').css("background-color","#f5f5f5");
        $('.table-sort').dataTable({
            "aaSorting": [[ 0, "desc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[1,2,3,4]}// 制定列不参与排序
            ]
        });
        $('.table-sort tbody').on( 'click', 'tr', function () {
            if ( $(this).hasClass('selected') ) {
                $(this).removeClass('selected');
            }
            else {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
        });
    });
</script>
<script type="text/javascript">


    function nature_detail(value){
        url="${ctx }/Nature/nature_detail?country_code="+value;
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
    function nature_update(value){
        url="${ctx }/Nature/nature_update?country_code="+value;
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
    function nature_delete(value){
        url="${ctx }/Nature/nature_delete";
        layer.confirm("确认删除吗？",['确认','取消'],function () {
            var parameter={country_code:value};
            $.post(url,parameter,function (data) {
                if(data=="删除成功"){
                    layer.msg(data,{icon:1,time:2000},function(){
                        location.reload(true);
                    })
                }else{
                    layer.msg(data,{icon:2,time:2000});
                }
            });
        })
    }
    function addNature(){
        url="${ctx }/Nature/nature_add";
        var index=layer.open({
            type:2,
            content:url
        });
        layer.full(index);
    }
</script>
</body>
</html>